package cn.wu.basic.utils;

import lombok.Data;

@Data
public class Result {
    //发送给前端的结果信息
    private  String msg;

    //发送给前端的true/false
    private Boolean success;

    public Result() {

    }


    public static Result a(){
        return new Result();
    }

    public Result success(String msg){
        return  a().setMsg(msg).setSuccess(true);
    }

    public Result fail(String msg){
        return  a().setMsg(msg).setSuccess(false);
    }
    public Result success(){
        return a().setMsg("操作成功！").setSuccess(true);
    }

    public Result fail(){
        return a().setMsg("操作失败！").setSuccess(false);
    }


    public Result(String msg, Boolean success) {
        this.msg = msg;
        this.success = success;
    }


    public Result setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Result setSuccess(Boolean success) {
        this.success = success;
        return this;
    }
}
